package com.spic.business.ioc.controller;

import com.spic.business.ioc.domain.IocCompliance;
import com.spic.business.ioc.service.IIocComplianceService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 达标情况 IOCController
 * @author spic
 * @date 2022-04-14
 */
@RestController
@RequestMapping("/ioc/compliance")
public class IocComplianceController extends BaseController
{
    @Autowired
    private IIocComplianceService iocComplianceService;

    /**
     * 查询达标情况 IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:compliance:list")
    @GetMapping("/list")
    public TableDataInfo list(IocCompliance iocCompliance)
    {
        startPage();
        List<IocCompliance> list = iocComplianceService.selectIocComplianceList(iocCompliance);
        return getDataTable(list);
    }

    /**
     * 导出达标情况 IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:compliance:export")
//    @Log(title = "达标情况 IOC", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IocCompliance iocCompliance) throws IOException
    {
        List<IocCompliance> list = iocComplianceService.selectIocComplianceList(iocCompliance);
        ExcelUtil<IocCompliance> util = new ExcelUtil<IocCompliance>(IocCompliance.class);
        util.exportExcel(response, list, "达标情况 IOC数据");
    }

    /**
     * 获取达标情况 IOC详细信息
     */
//    @PreAuthorize(hasPermi = "ioc:compliance:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(iocComplianceService.selectIocComplianceById(id));
    }

    /**
     * 新增达标情况 IOC
     */
//    @PreAuthorize(hasPermi = "ioc:compliance:add")
//    @Log(title = "达标情况 IOC", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IocCompliance iocCompliance)
    {
        return toAjax(iocComplianceService.insertIocCompliance(iocCompliance));
    }

    /**
     * 修改达标情况 IOC
     */
//    @PreAuthorize(hasPermi = "ioc:compliance:edit")
    @Log(title = "达标情况 IOC", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IocCompliance iocCompliance)
    {
        return toAjax(iocComplianceService.updateIocCompliance(iocCompliance));
    }

    /**
     * 删除达标情况 IOC
     */
//    @PreAuthorize(hasPermi = "ioc:compliance:remove")
    @Log(title = "达标情况 IOC", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(iocComplianceService.deleteIocComplianceByIds(ids));
    }
}
